package com.example.userservice.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.userservice.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {
    @Select("SELECT * FROM user")
    List<User> selectAll();

    @Select("SELECT * FROM user WHERE user_id = #{userId}")
    User selectByUserId(@Param("userId") Long userId);

    @Select("SELECT password FROM user WHERE user_id = #{userId}")
    String selectPasswordByUserId(@Param("userId") Long userId);

    @Select("SELECT password FROM user WHERE username = #{username}")
    String selectPasswordByUserName(@Param("username") String username);

    @Select("SELECT user_id FROM user WHERE username = #{username}")
    Long selectUserIdByUserName(@Param("username") String username);

    @Select("SELECT email FROM user WHERE user_id = #{userId}")
    String selectEmailByUserId(@Param("userId") Long userId);

    @Select("SELECT phone FROM user WHERE user_id = #{userId}")
    String selectPhoneByUserId(@Param("userId") Long userId);

    @Select("SELECT username FROM user WHERE user_id = #{userId}")
    String selectUserNameByUserId(@Param("userId") Long userId);
}
